function addComment(n,proId,score,orderId) {
	var imgList ="";
	var con=$.trim($("#"+proId+""+orderId+"text").val());
	var This=$(n);
	This.parent().siblings(".xdTipBox").find(".xd_tip").hide();
	var imgs = This.parents(".frameB").find(".commentAddPicDemo img");
	for(var i=0; i<imgs.length; i++){
		if(imgList!=""){
			imgList = imgList+ ","+ imgs.eq(i).attr("path");
		}else{
			imgList = imgs.eq(i).attr("path");
		}
	}
    jQuery.ajax({
        type: "post",
        url: "/jxcircle/selectLoginSession.htm?t="+getCurDate(),
        data: {},
        dataType:"json",
        async: true,
        success: function(data) {
            if (data && data.code == 0 && data.loginUser) {
                if (con == "") {
                    $.showAlert({"content":"请输入相关内容！", "type":"alarm" });
                    return false;
                }
                if (con == "请输入您的评论内容...") {
                    $.showAlert({"content":"请输入您的评论内容...", "type":"alarm" });
                    return false;
                }
                var numregular = /^\d+$/;
                var abcregular = /^[A-Za-z]+$/;
                var chinese = /[\u2E80-\u9FFF]/;
                var aa = /[//<>@*]+/;
                con = con.replace(/\s/g,'');
                if(abcregular.test(con) || numregular.test(con) || !chinese.test(con)){
                	$.showAlert({"content":"请输入有效的评价内容！", "type":"alarm" });
                	return;
                }
                var aa = /[//<>@*]+/;
                if(aa.test(con)){
                	$.showAlert({"content":"包含非法字符,请重新输入！", "type":"alarm" });
                	return;
                	}
                jQuery.ajax({
                	type:"post",
                	url:"/jxcircle/saveComment.htm?t="+getCurDate(),
                	data:{"proId":proId,"score":score,"content":con,"imgList":imgList,"orderId":orderId},
                	dataType:"json",
                	contentType:"application/x-www-form-urlencoded;charset=utf-8",
                	success:function(data){
                		if(data.code == '999'){
          					$.showAlert({"content":"不能输入敏感字符!", "type":"alarm" });
          					 return false;
   	                   	 }else if(data.code==-1){
   	                   		 $.showAlert({"content":"提交失败 !", "type":"fail" });
   	                		 return false; 
   	                   	 }else if(data.code==0){
   	            			$.showAlert({"content":"提交成功 !", "type":"success",
   	            			"callback":function(){window.location.href='/jxcircle/comment_wait.htm';}	
   	            			});
              				return false;
   	           			}else if(data.code == 4){
   	           				$.showAlert({"content":"参数错误!", "type":"alarm" });
   	               			return false;
   	           			}else if(data.code==1){
	   			    		window.location.href=domain_passprot+'/login.htm';
	   			    		return false;
   			    		}else if(data.code==2){
   			    			$.showAlert({"content":"您还未购买过此商品，暂时不能评论，感谢您对酒帝网的支持!", "type":"alarm" });
   	       					return false;
   	       				}else if(data.code==5){
   	       					$.showAlert({"content":data.message, "type":"alarm" });
   	   						return false;
   	   					}else if(data.code==6){
   	   						$.showAlert({"content":"您已经评论过此商品！", "type":"alarm" });
   	   						return false;
   	   					}else if(data.code==3){
   	   						$.showAlert({"content":"您操作频繁，请稍后再试！", "type":"alarm" });
   	   						return false;
   	   					}
                		}
                	}
                )}
            else{
            	window.location.href=domain_passprot+'/login.htm';
            	return false;
            }
            }
        }
    )};


function getCurDate(){   
    return new Date().getTime().toString();
 }
//回复评论
function reply(){
	var text = $("#repEvaTextId").val();
	var evaluateId = $("#evaluateID").val();
	var evaluateUserId = $("#evaluateUserId").val();
	var proId = $("#proId").val();
	if(text==""){
		alert("回复不能为空！")
		return;
	}
	
    jQuery.ajax({
        type: "post",
        url: "/jxcircle/selectLoginSession.htm?t="+getCurDate(),
        data: {},
        dataType:"json",
        async: true,
        success: function(data) {
            if (data && data.code == 0 && data.loginUser) {
                if (text == "") {
                    alert("请输入相关内容！");
                    return false;
                }
                var numregular = /^\d+$/;
                var abcregular = /^[A-Za-z]+$/;
                var chinese = /[\u2E80-\u9FFF]/;
                var aa = /[//<>@*]+/;
                text = con.replace(/\s/g,'');
                if(abcregular.test(text) || numregular.test(text) || !chinese.test(text)){
                	alert("请输入有效的回复内容！");return;
                }
                
                var aa = /[//<>@]+/;
                if(aa.test(text)){
                	alert("包含非法字符,请重新输入！");return;
                	}
                jQuery.ajax({
                	type:"post",
                	url:"/jxcircle/reply.htm",
                	data:{"text":text,"evaluateId":evaluateId,"evaluateUserId":evaluateUserId,"proId":proId},
                	dataType:"json",
                	contentType:"application/x-www-form-urlencoded;charset=utf-8",
                	success:function(data){
                		 if(data.code == '999'){
        					 alert('不能输入敏感字符!');
        					 return false;
                    	 }
                		if(data){
                			if(data.code==-1){
                			alert("提交失败 ! ");
                			return false;
                		}else{
                			if(data.code==0){
                				alert("提交成功 ! ");
                				$("#repEvaTextId").val("");
                				window.location.href="/jxcircle/comment_detail.htm?evaId=" +evaluateId+"&proId="+proId;
                				return false;
                			}else{if(data.code==1){
                				//alert("您还没有登录哦！");
                				window.location.href=domain_passprot+'/login.htm';
                				return false}
                			else{
                				if(data.code==5){
                					alert("回复内容含有敏感词，请过滤后再提交！");
                				}
                			  }
                			}
                			}
                		}
                		}
                	}
                )}
            else{
            	//alert("您还没有登录哦！");
            	window.location.href=domain_passprot+'/login.htm';
            	return false;
            }
            }
        }
    )
}

//回复回复
function reply(userId,num){
	var text = $("#"+num).val();
	var evaluateId = $("#evaluateID").val();
	var proId = $("#proId").val();
	if(text==""){
		alert("回复不能为空！")
		return;
	}
	
    jQuery.ajax({
        type: "post",
        url: "/jxcircle/selectLoginSession.htm?t="+getCurDate(),
        data: {},
        dataType:"json",
        async: true,
        success: function(data) {
            if (data && data.code == 0 && data.loginUser) {
                if (text == "") {
                    alert("请输入相关内容！");
                    return false;
                }
//                if (con == "请输入您的评论内容...") {
//                    alert("请输入您的评论内容...");
//                    return false;
//                }
                var aa = /[//<>@]+/;
                if(aa.test(text)){
                	alert("包含非法字符,请重新输入！");return;
                	}
                alert("dengluyanzhengwancheng");
                jQuery.ajax({
                	type:"post",
                	url:"/jxcircle/reply.htm",
                	data:{"text":text,"evaluateId":evaluateId,"evaluateUserId":userId,"proId":proId},
                	dataType:"json",
                	contentType:"application/x-www-form-urlencoded;charset=utf-8",
                	success:function(data){
                		 if(data.code == '999'){
        					 alert('不能输入敏感字符!');
        					 return false;
                    	 }
                		if(data){
                			if(data.code==-1){
                			alert("提交失败 ! ");
                			return false;
                		}else{
                			if(data.code==0){
                				alert("提交成功 ! ");
                				$("#repEvaTextId").val("");
                				window.location.href="/jxcircle/comment_detail.htm?evaId=" +evaluateId+"&proId="+proId;
                				return false;
                			}else{if(data.code==1){
                				//alert("您还没有登录哦！");
                				window.location.href=domain_passprot+'/login.htm';
                				return false}
                			else{
//                				if(data.code==2){
//                					alert("您还未购买过此商品，暂时不能评论，感谢您对酒帝网的支持");
//                					return false;
//                				}else{
//                					if(data.code==3){
//                						alert("您操作频繁，请稍后再试！");
//                						return false;
//                					}
//                				}
                				}
                			}
                			}
                		}
                		}
                	}
                )}
            else{
            	//alert("您还没有登录哦！");
            	window.location.href=domain_passprot+'/login.htm';
            	return false;
            }
            }
        }
    )
}


//我的收藏页面商品加入购物车的方法
function addCart(goodsId){ 
	addSkuToCart(goodsId,1,"",toCartCallBack);
}
// 加入购物车的回调函数
var toCartCallBack = function(data){
	if (data.status == 1){
		 alert("添加成功！"); 
	}
}

